﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace homework3_basic_arithmetic_operation
{
    internal class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("请输入您要给数组元素赋的所有值，每两个值之间用空格隔开：");

            //读取数字串
            string str = Console.ReadLine();

            //切割成字符串数组
            string[] strArr = str.Split(' ');


            //将其中的数存到整数数组中
            int[] arr = new int[strArr.Length];
            for (int i = 0; i < strArr.Length; i++)
                arr[i] = int.Parse(strArr[i]);

            //求最值、均值、累加和
            int min = arr[0], max = arr[0], sum = 0;
            for (int i = 0; i < arr.Length; i++)
            {
                if (arr[i] < min) min = arr[i];
                else if (arr[i] > max) max = arr[i];
                sum += arr[i];
            }
            double avg = (double)sum / arr.Length;
            Console.WriteLine("您设定的数组中：\n最大值为：{0}\n最小值为：{1}\n平均值为：{2}\n元素和为：{3}", max, min, avg, sum);

        }
    }
}
